$import('com.hh.global.BaseSimpleTreePanel');
Ext.define('com.hh.global.tree.BaseSimpleTreePanel', {
	extend : 'com.hh.global.BaseSimpleTreePanel',
	beInit : function() {
		var panel = this;
		this.toolbarItems = [ {
			iconCls : 'add',
			text : '添加根节点',
			handler : function() {
				panel.doAddRoot();
			}
		} ];
	},
	doAddRoot : function() {
		var page = this;
		var editPageUrl = this.editPage;
		var win = ExtUtil.create(editPageUrl, {
			id : this.id + '-' + editPageUrl.replace(/\./g, ''),
			addType : 'root',
			parentPanel : this,
			callbackRefresh : function() {
				page.store.load();
			}
		});
		win.show();
	},
	doAdd : function() {
		var page = this;
//		var record = page.tree.getSelectionModel().getSelection()[0];
		var record =	page.tree.getSelectionModel().lastFocused;
		if (record != null) {
			if (record.get('leaf')) {
				ExtFrame.info('不能给叶子节点添加子节点！！');
				return;
			}
		}
		var editPageUrl = this.editPage;
		var win = ExtUtil.create(editPageUrl, {
			id : this.id + '-' + editPageUrl.replace(/\./g, ''),
			parentPanel : this,
			callbackRefresh : function() {
				page.store.load();
			}
		});
		win.show();
	}
});